-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rouge: Add support for resizing raw images #120
Conversation
@rshym suggested that we should make resize true by default to make behavior more consistent with the other blocks. Will it be a better approach? |
I strongly disagree with the statement mentioned above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! With that small nit fixed:
Reviewed-by: Volodymyr Babchuk <[email protected]>
moulin/rouge/block_entry.py
Outdated
|
||
fsize = os.path.getsize(self._fname) | ||
|
||
if (self._resize and fsize < self._size): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is Python, not C :)
No need for parentheses
Yes. I believe in "least surprise" principle. So make it |
b6018cf
to
d532bc9
Compare
Also improved the error messaging slightly, I hope it's okay |
|
@@ -93,3 +93,13 @@ def mmd(img: BinaryIO, folders: list): | |||
args.extend(folders) | |||
|
|||
_run_cmd(args) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required by python styling guides
moulin/rouge/block_entry.py
Outdated
ext_utils.resize2fs(os.path.join(tmpd, os.path.basename(self._fname))) | ||
except subprocess.CalledProcessError as e: | ||
log.error( | ||
"%s is not resizable. If you don't need to resize it, set 'resize: false' in the yaml.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I believe there are multiple reasons why resize2fs may fail.
Thinking of it, this is much more complex task, because raw image could be not only ext2fs, but FAT, for example...
To unblock us, please rewrite the error message like this:
"Failed to resize %s partition. Right now we support resizing for EXT{2,3,4} partitions only. If you don't really want to resize it, please remove "size" parameter or set "resize" to false. If you want to resize some other type of partitions - please create a PR or notify us at least".
Also, please open issue for mouling about this.
Add new "resize" option to the raw_image block, which allows rouge to resize the raw_image to the size set in the block. It is enabled by default and can be disabled manually. This is useful when the image size needs to be changed frequently, or multiple images need to be created from the same source files, as it allows to skip the rootfs rebuild step. Images are copied to a temporary directory before resizing to preserve the original build artifacts. The temporary directory is created in the current working directory to prevent filling the system's /tmp with large images. Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]> Reviewed-by: Ruslan Shymkevych <[email protected]>
There is a new feature for "rouge" was added. Let's bump moulin version. Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]> Reviewed-by: Ruslan Shymkevych <[email protected]>
Add new "resize" to the raw_image block, which allows rouge to resize the raw_image to the size set in the block.
This is useful when the image size needs to be changed frequently, or multiple images need to be created from the same source files, as it allows to skip the rootfs rebuild step.
Images are copied to a temporary directory before resizing to preserve the original build artifacts. The temporary directory is created in the current working directory to prevent filling the system's /tmp with large images.